﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Transaction.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the Transaction type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Windows.Client.Model
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// Defines the <seealso cref="Transaction"/> type.
    /// </summary>
    public class Transaction : ModelBase
    {
        /// <summary>
        /// Backing field for IsTransferTransaction
        /// </summary>
        private bool _isTransferTransaction;

        /// <summary>
        /// Backing field for Transaction ID
        /// </summary>
        private int _transactionId;

        /// <summary>
        /// Backing field for title
        /// </summary>
        private string _title;

        /// <summary>
        /// Backing f0ield for Amount
        /// </summary>
        private decimal _amount;

        /// <summary>
        /// Backing field for Account
        /// </summary>
        private int _account;

        /// <summary>
        /// Backing field forTransaction Type
        /// </summary>
        private TransactionTypes _transactionType;

        /// <summary>
        /// Backing field for details
        /// </summary>
        private string _details;

        /// <summary>
        /// Backing field for date
        /// </summary>
        private DateTime _date;

        /// <summary>
        /// Backing field for linked transaction date
        /// </summary>
        private DateTime _linkedTransactionDate;

        /// <summary>
        /// Backing field for linked transaction account
        /// </summary>
        private int _linkedTransactionAccount;

        /// <summary>
        /// Backing field for related transaction id
        /// </summary>
        private int _relatedTransactionId;

        /// <summary>
        /// Gets or sets the transaction id.
        /// </summary>
        /// <value>
        /// The transaction id.
        /// </value>
        public int TransactionId
        {
            get
            {
                return _transactionId;
            }

            set
            {
                if (_transactionId != value)
                {
                    _transactionId = value;
                    OnPropertyChanged("TransactionId");
                }
            }
        }

        /// <summary>
        /// Gets or sets the title.
        /// </summary>
        /// <value>
        /// The title.
        /// </value>
        public string Title
        {
            get
            {
                return _title;
            }

            set
            {
                if (_title != value)
                {
                    _title = value;
                    OnPropertyChanged("Title");
                }
            }
        }

        /// <summary>
        /// Gets or sets the amount.
        /// </summary>
        /// <value>
        /// The amount.
        /// </value>
        public decimal Amount
        {
            get
            {
                return _amount;
            }

            set
            {
                if (_amount != value)
                {
                    _amount = value;
                    OnPropertyChanged("Amount");
                }
            }
        }

        /// <summary>
        /// Gets or sets the account.
        /// </summary>
        /// <value>
        /// The account.
        /// </value>
        public int Account
        {
            get
            {
                return _account;
            }

            set
            {
                if (_account != value)
                {
                    _account = value;
                    OnPropertyChanged("Account");
                }
            }
        }

        /// <summary>
        /// Gets or sets the details.
        /// </summary>
        /// <value>
        /// The details.
        /// </value>
        public string Details
        {
            get
            {
                return _details;
            }

            set
            {
                _details = value;
                OnPropertyChanged("Details");
            }
        }

        /// <summary>
        /// Gets or sets the type of the transaction.
        /// </summary>
        /// <value>
        /// The type of the transaction.
        /// </value>
        public TransactionTypes TransactionType
        {
            get
            {
                return _transactionType;
            }

            set
            {
                if (_transactionType != value)
                {
                    _transactionType = value;
                    IsTransferTransaction = TransactionType == TransactionTypes.Transfer;
                    OnPropertyChanged("TransactionType");
                }
            }
        }

        /// <summary>
        /// Gets or sets the date.
        /// </summary>
        /// <value>The date of transaction</value>
        public DateTime Date
        {
            get
            {
                return _date;
            }

            set
            {
                _date = value;
                OnPropertyChanged("Date");
            }
        }

        /// <summary>
        /// Gets or sets the tags.
        /// </summary>
        /// <value>The comma separated list of tags. </value>
        public IEnumerable<Tag> Tags { get; set; }

        /// <summary>
        /// Gets or sets the account.
        /// </summary>
        /// <value>
        /// The account.
        /// </value>
        public int LinkedTransactionAccount
        {
            get
            {
                return _linkedTransactionAccount;
            }

            set
            {
                _linkedTransactionAccount = value;
                OnPropertyChanged("LinkedTransactionAccount");
            }
        }

        /// <summary>
        /// Gets or sets the date.
        /// </summary>
        /// <value>The date of transaction</value>
        public DateTime LinkedTransactionDate
        {
            get
            {
                return _linkedTransactionDate;
            }

            set
            {
                _linkedTransactionDate = value;
                OnPropertyChanged("LinkedTransactionDate");
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [new account].
        /// </summary>
        /// <value>
        /// True if new account; otherwise, false.
        /// </value>
        public bool IsTransferTransaction
        {
            get
            {
                return _isTransferTransaction;
            }

            set
            {
                if (_isTransferTransaction != value)
                {
                    _isTransferTransaction = value;
                    OnPropertyChanged("IsTransferTransaction");
                }
            }
        }

        /// <summary>
        /// Gets or sets the related transaction id.
        /// </summary>
        /// <value>
        /// The related transaction id.
        /// </value>
        public int RelatedTransactionId
        {
            get
            {
                return _relatedTransactionId;
            }

            set
            {
                _relatedTransactionId = value;
                OnPropertyChanged("RelatedTransactionId");
            }
        }
    }
}